//
//  HomeProgramaCell.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/8.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "HomeProgramaCell.h"
#import "HomePrograSubCell.h"
#import "GoodsCategoryVC.h"
#import "EveryDayTaskVC.h"
#import "HomeCollecLayout.h"
#import "PreferenceGoodsVC.h"
@interface HomeProgramaCell ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView;

@end

@implementation HomeProgramaCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.myCollectionView registerNib:[UINib nibWithNibName:NSStringFromClass([HomePrograSubCell class]) bundle:nil] forCellWithReuseIdentifier:[HomePrograSubCell identifierStr]];
    self.myCollectionView.scrollEnabled = NO;
    self.myCollectionView.delegate = self;
    self.myCollectionView.dataSource = self;
    self.contentView.backgroundColor = viewBgGrey;
    
    

    // Initialization code
}

- (void)setModels:(NSArray<HomeNavModel *> *)models{
    
    _models = models;
    
 
    [self.myCollectionView reloadData];
    
}




- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    
    if (self.models == nil) {
        return 0;
    } else {
        return self.models.count;
    }
    
    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    HomePrograSubCell *cell = (HomePrograSubCell *)[collectionView dequeueReusableCellWithReuseIdentifier:[HomePrograSubCell identifierStr] forIndexPath:indexPath];
    
    cell.model = self.models[indexPath.item];
    
    return cell;
    
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
//    ".h"

    if (indexPath.item == 0) {
        
        [self.viewController.navigationController pushViewController:[[GoodsCategoryVC alloc]init] animated:YES];
        
    } else if (indexPath.item == 1){
     
    [self.viewController.navigationController pushViewController:[[PreferenceGoodsVC alloc]initWithCollectionViewLayout:[[HomeCollecLayout alloc]init]] animated:YES];
        
    }else if (indexPath.item == 2){
        
        [self.viewController.navigationController pushViewController:[[EveryDayTaskVC alloc]initWithStyle:UITableViewStylePlain] animated:YES];

    }else if (indexPath.item == 3){
        
        [self.viewController.navigationController pushViewController:[[EveryDayTaskVC alloc]initWithStyle:UITableViewStylePlain] animated:YES];

    }
    
    
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
